package com.bluesky.drcp.business.service;

import java.util.Map;
import java.util.Vector;

import org.wix.wsCaller.DynamicInvoker;

public class SoapAuthenticationService implements AuthenticationService {
	private String location;

	private String serviceName;

	private String portName;

	private String operationName;

	public String getOperationName() {
		return operationName;
	}

	public void setOperationName(String operationName) {
		this.operationName = operationName;
	}

	public boolean login(String userId, String password) {

		try {
			DynamicInvoker invoker = new DynamicInvoker(location);
			Vector<Object> paramList = new Vector<Object>();
			paramList.add(userId);
			paramList.add(password);

			Map returnList = invoker.invoke(serviceName, portName,
					operationName, paramList);
			Object value = returnList.get(">" + operationName + "Response>"
					+ operationName + "Result");

			return value.toString().equals("true");

		} catch (Exception e) {
		}

		return false;
	}

	public String getLocation() {
		return location;
	}

	public String getPortName() {
		return portName;
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public void setPortName(String portName) {
		this.portName = portName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}
}
